/* rcsois3a.p - Release Management Customer Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.3.3.6 $                                                               */
/*V8:ConvertMode=NoConvert                                                    */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96     BY: TSI *K005*                */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98     BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1    LAST MODIFIED: 07/07/99     BY: *N004* Steve Nugent       */
/* REVISION: 9.1    LAST MODIFIED: 03/28/00     BY: *K25V* Surekha Joshi      */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00     BY: *N0KP* Mark Brown         */
/* Revision: 1.3.3.4   BY: Jean Miller        DATE: 03/22/01  ECO: *P008*     */
/* Revision: 1.3.3.5   BY: Dan Herman         DATE: 08/15/01   ECO: *P01L*    */
/* $Revision: 1.3.3.6 $        BY: Rajaneesh S.       DATE: 08/26/01   ECO: *M1J8*    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* INPUT PARAMETERS */
define input parameter abs_recid as recid.

/* LOCAL VARIABLES */
define variable par_id as character no-undo.
define variable ship_from as character no-undo.
define shared variable confirm_mode like mfc_logical no-undo.
define variable using_seq_schedules like mfc_logical initial no no-undo.
define     shared variable auto_post like mfc_logical.
define variable err_flag               as integer   no-undo.
define variable l_db                 like global_db no-undo.


/* VARIABLE DEFINITIONS FOR gpfile.i */
{gpfilev.i}

/* DETERMINE IF SEQUENCE SCHEDULES IS INSTALLED */
{gpfile.i &file_name = """"rcf_ctrl""""}

if can-find (mfc_ctrl where
             mfc_field = "enable_sequence_schedules" and
             mfc_logical) and file_found
then
   using_seq_schedules = yes.

{cclc.i} /*CHECK FOR ENABLEMENT OF CONTAINER AND LINE CHARGES*/

find abs_mstr where recid(abs_mstr) = abs_recid no-lock.

assign
   par_id    = abs_id
   ship_from = abs_shipfrom.

for each abs_mstr
   where abs_shipfrom = ship_from
     and abs_par_id   = par_id
exclusive-lock:

   if abs_id begins "I" then do:

      for each absr_det
         where absr_shipfrom = abs_shipfrom
           and absr_id       = abs_id
      exclusive-lock:

      for first sod_det
         fields(sod_line sod_nbr sod_site)
         where sod_nbr  = absr_nbr
           and sod_line = absr_line
         no-lock:
      end. /* FOR FIRST sod_det */

      if available sod_det
      then do:
         l_db = global_db.

         for first si_mstr
            fields(si_db si_site)
            where si_site = sod_site
            no-lock:
         end. /* FOR FIRST si_mstr */

         if  available si_mstr
         and si_db <> global_db
         then do:
            {gprun.i ""gpalias3.p"" "(si_db, output err_flag)" }
         end. /* IF AVAILABLE si_mstr ... */

         /* UPDATE schd_ship_qty IN THE INVENTORY DATABASE */
         {gprun.i ""rcschup.p""
             "(input absr_nbr,
               input absr_qty,
               input absr_line,
               input absr_type,
               input absr_date,
               input absr_interval,
               input absr_reference,
               input absr_rlse_id,
               input absr_time)"}

         if l_db <> global_db
         then do:
            {gprun.i ""gpalias3.p"" "(l_db, output err_flag)" }
         end. /* IF l_db <> global_db */

      end. /* IF AVAILABLE sod_det */


         if execname = "rcunis.p" then
            absr_cnfrmd = false.
         else
            absr_cnfrmd = true.

      end. /* for each absr_det */

      /* UPDATE CONFIRMED STATUS OF SEQ SCHEDULES IN abss_det */
      if using_seq_schedules then do:
         {gprunmo.i
            &program=""rcabsscf.p""
            &module="ASQ"
            &param="""(input recid(abs_mstr))"""}
      end. /* if using_seq_schedules */

      /* Update confirm status of line charges in absl_det */
      if using_line_charges then do:
         {gprunmo.i
            &program=""rcabsccf.p""
            &module="ACL"
            &param="""(input abs_id,
                       input abs_shipfrom,
                       input confirm_mode,
                       input auto_post,
                       input yes)"""}
      end. /* if using_line_charges */

   end. /* if abs_id begins "i" */

   /* Update confirm status of container charges in abscc_det */
   if using_container_charges and abs_id begins "c" then do:
      {gprunmo.i
         &program=""rcabsccf.p""
         &module="ACL"
         &param="""(input abs_id,
                    input abs_shipfrom,
                    input confirm_mode,
                    input auto_post,
                    input no)"""}
   end. /* if using_container_charges */

   {gprun.i ""rcsois3a.p"" "(input recid(abs_mstr))"}.

end. /* for each abs_mstr */
